﻿using UnityEngine;

public class SkeletonMoveState:SkeletonGroundState
{
    public SkeletonMoveState(ControllerBase controller, StateMachineBase stateMachine
        , string stateName, string animatorParameter = null) : base(controller, stateMachine, stateName, animatorParameter)
    {
    }

    public override void Update()
    {
        base.Update();
        if (SelfController.isWall||!SelfController.isGround)
        {
            stateMachine.ChangeState(Setting.idle);
            SelfController.Flip();
            return;
        }

        if (CheckCanUpdate())
        {
            SelfController.SetVelocity(new Vector2(SelfController.GetEnemyStateInfo().MoveSpeed*SelfController.faceDir
                , controller.GetVelocity().y));
        }
        /*if (SelfController.isFrozen)// 被冻结
        {
            SelfController.SetVelocity(new Vector2(0
                , controller.GetVelocity().y));
        }
        else
        {
            SelfController.SetVelocity(new Vector2(SelfController.GetEnemyInfo().MoveSpeed*SelfController.faceDir
                , controller.GetVelocity().y));
        }*/
    }
}